package poswar.contribute.mbean;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;

import poswar.contribute.model.Post;
import poswar.contribute.util.FacesUtils;



@ManagedBean
@RequestScoped
public class PostBean {
	private String post;
	
	@ManagedProperty("#{boardBean}")
	private BoardBean boardBean;
 
	@ManagedProperty("#{userBean}")
	private UserBean userBean;
	
	public void doPost() {
		if (FacesUtils.isEmpty(post)) 
			return;
		
		boardBean.post(Post.build(userBean.getEmail(), post));
		post = "";
	}
	
	public void refresh() {
		
	}
	
	public String getPost() {
		return post;
	}

	public void setPost(String post) {
		this.post = post;
	}

	public String getEmail() {
		return userBean.getEmail();
	}

	public void setEmail(String email) {
		userBean.setEmail(email);
	}

	public BoardBean getBoardBean() {
		return boardBean;
	}

	public void setBoardBean(BoardBean boardBean) {
		this.boardBean = boardBean;
	}

	public UserBean getUserBean() {
		return userBean;
	}

	public void setUserBean(UserBean userBean) {
		this.userBean = userBean;
	}

	
	
}
